#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClicked);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClicked()
{
    this->setWindowTitle("修改窗体标题1");
    qDebug() <<"handleClicked";
}

void Widget::handleClicked2()
{
    this->setWindowTitle("修改窗体标题2");
    qDebug() <<"handleClicked 2";
}


void Widget::on_pushButton_2_clicked()
{
    //1.信号和槽断开连接
    disconnect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClicked);

    //2.将pushButton的clicked信号和新的槽函数绑定
    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClicked2);
}
